package com.itheima.dao;

import com.github.pagehelper.Page;
import com.itheima.entity.QueryPageBean;
import com.itheima.pojo.CheckGroup;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface CheckGroupDao {
    @Insert("insert into t_checkgroup(code,name,helpCode,sex,remark,attention) values(#{code},#{name},#{helpCode},#{sex},#{remark},#{attention})")
    @Options(useGeneratedKeys=true,keyProperty="id",keyColumn ="id")
    int add(CheckGroup checkGroup);
     @Insert("insert into t_checkgroup_checkitem values(#{checkGroupId},#{checkItemId})")
    void addCheckGroupAndCheckItem(@Param("checkGroupId") int checkGroupId, @Param("checkItemId") Integer checkItemId);
    @Select("select * from t_checkgroup where code like #{queryString} or name like #{queryString} or helpCode like #{queryString} ")
    Page<CheckGroup> findPage(QueryPageBean queryPageBean);
    @Delete("delete from t_checkgroup_checkitem where checkgroup_id=#{id} or checkitem_id=#{id}")
    void deleteCentre(int id);
    @Delete("delete from t_checkgroup where id=#{id}")
    void deleteById(int id);
    @Select("select checkitem_id from t_checkgroup_checkitem where checkgroup_id=#{id}")
    List<Integer> findItemIdsByGroupId(int id);
    @Select("select * from t_checkgroup where id=#{id}")
    CheckGroup findcheckGroupById(int id);
    @Update("update t_checkgroup set code = #{code},name= #{name},helpCode=#{helpCode},sex=#{sex},remark=#{remark},attention=#{attention} where id=#{id}")
    void update(CheckGroup checkGroup);
    @Select("select * from t_checkgroup")//查询所有
    List<CheckGroup> findAll();
}
